package didi;

import java.util.Scanner;

public class Main1 {

    public static int resolve(String str, int n, int m){
        int min = Integer.MAX_VALUE;

        for(int flag=0;flag<26;flag++) {

            int count = 0;
            for (int i = 0; i < n; ) {
                if (str.charAt(i) - 'a' != flag) {
                    count++;
                    i += m;
                } else {
                    i++;
                }
            }

            min = min < count ? min : count;
        }

        return min;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt();
        int m = sc.nextInt();
        String str = sc.next();
        int resolve = resolve(str, n, m);
        System.out.print(resolve);
    }
}
